package util;

import java.util.HashMap;
import java.util.Map;

public class BookStorage {
    static Map<Integer, Book> books;

    static {
        books = new HashMap<Integer, Book>();
        books.put(1, new Book(1, "HEAD FIRST JAVA"));
        books.put(2, new Book(2, "TDD by example"));
        books.put(3, new Book(3, "Refactor"));
    }

    public static Book get(int id) {
        return books.get(id);
    }


    public static String outputBooksList() {
        StringBuffer booksList = new StringBuffer();
        for (int id = 1; id <= books.size(); id++) {
            booksList.append(books.get(id) + "\n");
        }
        return booksList.toString();
    }

    public static boolean isContain(int bookId) {
        return books.containsKey(bookId);
    }
}
